Repository navigation
Leave an active button with an empty value blank instead of showing its field name (#459) - #489
Merged
Merged
Conversation
…ts field name A submit, reset or script button with value="" wrote its field name as its /MK /CA caption, and its appearance drew the name as well, while the same button drawn without active forms, and in a browser, has no caption. The caption is now written as given, even when empty. A button whose caption was never set, such as an image button, still falls back to its field name. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
jakejackson1
force-pushed
the
fix/459-blank-empty-button-caption
branch
from
September 28, 2026 02:47
16cc1ba to
484bb38
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
useActiveFormson, a submit, reset or script button withvalue=""showed its field name as its caption. The same button drawn without active forms, and in a browser, is blank.Cause.
Form::_putform_bt()wrote the field name as/MK /CA,/RCand/ACwhenever the caption was falsy. #387's appearance stream copied that fallback ($value === '' ? $name : $value) so it would match what a viewer draws. Since #438, an unnamed button gets a generated name ("Submit_1"), so an unnamed button withvalue=""showed that as well. With embedded fonts,/CAwas already an empty UTF-16 string (a lone BOM), which is truthy, but the appearance still drew the name.Fix.
buttonCaptions(). A caption set throughSetFormButtonText()is written as it is, even when empty.null). That covers image buttons, whose icon replaces the caption (/TP 1), and callers who useSetFormSubmit()/SetFormReset()/SetJSButton()directly withoutSetFormButtonText(). Their output does not change./CA.valueattribute is not affected.Tag\Inputgives it "Submit", "Reset" or "Button", and both modes draw that.value="0"used to show its name because"0"is falsy. It now shows "0".Tests.
tests/Mpdf/ButtonCaptionTest.phpcovers submit, reset and script buttons with an empty value, no value, and a value, plus an unnamed submit withvalue="":/CA,/RCand/ACare the value, and the appearance draws it;/CA.A new snapshot,
empty-button-caption(tests/Snapshots/EmptyButtonCaptionSnapshotTest.php), draws active submit, reset and script buttons withvalue="", no value,value="Send"andvalue="0", plus an unnamed submit. Before the change, the empty-value buttons show their names squeezed into the button ("sub", "reset", "butt", "Sub"). After it, they are blank.Without the change in
src/Form.php, 9 of the unit tests and the new snapshot fail. The full suite, phpcs and PHPStan pass. No existing snapshot fixture changes.Base. PR #448 (#408) is on
gravitypdf. PR #441 (#433) was merged intofeature/pdfa-2-conformance, and that branch came intogravitypdfthrough #330 as a rewritten commit (16dc47b), so this change is made on top of both.Upgrade note
In active forms (
useActiveForms), a push button (<input type="submit">,type="reset"ortype="button") with an emptyvaluenow has an empty caption. Previously it showed the field'sname, or a generated name such asSubmit_1if it had none. This is what the same button looks like without active forms, and in a browser. To keep a caption, give the button avalue, or leave out thevalueattribute to get the default "Submit", "Reset" or "Button".Fixes #459
🤖 Generated with Claude Code